home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr46 / multi_c1.zip / MULTI_C.H < prev    next >
C/C++ Source or Header  |  1992-11-08  |  6KB  |  346 lines

  1. /********************************************************************
  2.                                MULTI-APP CORE 
  3.                      Copyright 1992 by Jeff Heaton
  4.                             All Rights Reserved
  5.                             
  6.     COMPAT: DOS,MAC & WINDOWS
  7.                             
  8. MicroGenesis Software
  9. P.O. Box 25534
  10. St. Louis, Mo 63125
  11.  
  12.  
  13. ********************************************************************/
  14.  
  15. #ifndef __MULTI_C_H
  16. #define __MULTI_C_H
  17.  
  18.  
  19. // UnComment these lines to make the windows library.
  20. //#define NOATOM
  21. //#include "windows.h"
  22. //#define IBM
  23. //#define msWINDOWS
  24.  
  25. // First lets find out what platform we are on
  26. #ifndef msWINDOWS
  27. #ifndef THINK_C
  28. #define IBM
  29. #else
  30. #define MAC
  31. #endif
  32. #endif
  33.  
  34. // Path separation, is it:
  35. // C:\DOS\file
  36. //      or
  37. // MacintoshHD:System:file
  38. #ifdef MAC
  39. #define PATH ':'
  40. #endif
  41. #ifdef IBM
  42. #define PATH '\\'
  43. #endif
  44.  
  45. // Define data types for BYTEs and WORDs
  46. typedef unsigned char BYTE;
  47. typedef unsigned WORD;
  48. typedef unsigned long DWORD;
  49.  
  50. // This is the standard MULTI-APP way of storeing integers in binary files
  51. // and communication.  Not all platforms(particularly Intel and Motorola)
  52. // store hi/lo byte in the same order.
  53. #define HI_BYTE(x) (x/256)
  54. #define LO_BYTE(x) (x-(HI_BYTE(x)*256))
  55. #define BYTE_COMB(x,y) ((x*256)+y)
  56.  
  57. #ifdef IBM
  58. #define COM1_base    0x3f8
  59. #define COM1_irq     4
  60. #define COM2_base    0x2f8
  61. #define COM2_irq     3
  62. #define COM3_base    0x3e8
  63. #define COM3_irq     4
  64. #define COM4_base    0x2e8
  65. #define COM4_irq     3
  66. #endif
  67.  
  68. #define ALP_IN 4096
  69.  
  70. // Some communications standards
  71. #define    NUL        0x00
  72. #define SOTT    0x01
  73. #define STX        0x02
  74. #define ETY        0x03
  75. #define EOT        0x04
  76. #define ENQ        0x05
  77. #define    ACK        0x06
  78. #define BEL        0x07
  79. #define BKSPC    0x08
  80. #define HZTAB    0x09
  81. #define LF        0x0a
  82. #define VTAB    0x0b
  83. #define FF        0x0c
  84. #define CR        0x0d
  85. #define SO        0x0e
  86. #define SI        0x0f
  87. #define DLE        0x10
  88. #define XON        0x11
  89. #define DC2        0x12
  90. #define XOFF    0x13
  91. #define    DC4        0x14
  92. #define NAK        0x15
  93. #define SYN        0x16
  94. #define ETB        0x17
  95. #define CAN        0x18
  96. #define EM        0x19
  97. #define    SUB        0x1a
  98. #define ESC        0x1b
  99. #define FS        0x1c
  100. #define GS        0x1d
  101. #define RS        0x1e
  102. #define US        0x1f
  103.  
  104. // Some external functions you must provide for MULTI-APP
  105. void alp_failed(void);
  106. void debug(char *,...);
  107. void idle_function(void);
  108. void update_menus(void);
  109.  
  110. // MULTI-APP Global Functions
  111. int        decode    (void *dest,void *source);
  112. int        encode    (void *dest,void *source,int length);
  113. long    timer_set(int tenths);
  114. int     timer_check    (long tm);
  115. void     timer_wait    (long tm);
  116. void     sleep    (int tenths);
  117. void     c2pas    (char *str);
  118. void     pas2c    (char *str);
  119. void     updcrc    (unsigned char b);
  120. void     beep    (void);
  121. int     is_color_computer(void);
  122. void     path    (char *p);
  123. void     strsplice    (char **dest,char *str1,char *str2);
  124. void     strins    (char *str,char *ins,int n);
  125. char     includes(char *str,char key);
  126.  
  127.  
  128. extern unsigned short crc;
  129.  
  130. // A5 For the Mac
  131. #ifdef MAC
  132. pascal long SetUpA5  (void)      ={0x2E8D,0x2A78,0x0904};
  133. pascal long RestoreA5(long newA5)={0x2F4D,0x0004,0x2A5F};            
  134. #endif
  135.  
  136. // Definitions used by ATOM.CPP
  137.  
  138. class ATOM
  139. {
  140.     public:
  141.     ATOM();
  142.  
  143.     ATOM *next;// Next atom in a linked list
  144. };
  145.  
  146. class LIST:public ATOM
  147. {
  148.     public:
  149.  
  150.     LIST(void);
  151.  
  152.     void add(ATOM *atom);
  153.     void del(ATOM *atom);
  154.  
  155.     void first_element(void);
  156.     void forward(void);
  157.     void pos(long p);
  158.     virtual int  comp(ATOM *a1,ATOM *a2);
  159.  
  160.         ATOM *first,*current;
  161. };
  162.  
  163.  
  164.  
  165. // Defubutuibs used by DEVICE.CPP
  166. class DEVICE:public LIST
  167. {
  168.     public:
  169.     virtual int put(BYTE ch);
  170.     virtual int putstr(char *str);
  171.     virtual int goxy(int x,int y);
  172.     virtual int inverse(void);
  173.     virtual int normal(void);
  174.     virtual BYTE get(BYTE *ch);
  175.     virtual BYTE wait2get(BYTE *ch);
  176.     virtual int hit(void);
  177.     virtual int reset(void);
  178.     virtual int ceol(void);
  179.     virtual int wherex(void);
  180.     virtual int wherey(void);
  181.     virtual int printf(char *format,...);
  182.     int getstr(char *str,int len);
  183. };
  184.  
  185.  
  186.  
  187. // Definitions used by COMIO.CPP
  188.  
  189.  
  190. class COMIO:public DEVICE
  191. {
  192.     public:
  193.     COMIO(void);
  194.     ~COMIO();
  195.     int init(int p);
  196.     virtual int put(BYTE ch);
  197.     virtual BYTE get(BYTE *ch);
  198.     virtual int putstr(char *str);
  199.     virtual int hit(void);
  200.     virtual void baud(long r);
  201.     virtual void disconnect(void);
  202.     virtual int timed_get(BYTE *ch,int secs);
  203.  
  204.     void flush_out(void);
  205.     void flush_in(void);
  206.     void purge_out(void);
  207.     void purge_in(void);
  208.     char detect_carrier;
  209.     void flow(int i);
  210.  
  211.     void dtr(int i);
  212.     char carrier(void);
  213.     long lockbaud;
  214.     int direct,no_modem;
  215.     int flow_control;
  216.     long baudrate,bps;
  217.     private:
  218. #ifdef MAC
  219.         short in_ref,out_ref;
  220. #endif
  221.     int port;
  222. };
  223.  
  224.  
  225.  
  226.  
  227. // Definitions used by ALP.CPP
  228.  
  229.  
  230. struct ALP:public COMIO
  231. {
  232.  
  233.     ALP();
  234.     void update(void);// Call this as often as possable
  235.     void intr(void);
  236.     int check(void);  // Check for ALP-compat device on remote side
  237.     void transmit(void); // transmit a packet
  238.  
  239.     // Replacements for CONIO functions:
  240.     virtual int put(BYTE ch);
  241.     virtual BYTE get(BYTE *ch);
  242.     virtual int hit(void);
  243.     virtual void disconnect();
  244.     
  245.     // Incomeing queue
  246.     void push(BYTE ch);
  247.     BYTE pop(void);
  248.     
  249.     void input(BYTE ch);
  250.  
  251.     BYTE hi,lo;
  252. BYTE in_packet[2048];
  253. BYTE uncomp[2048];
  254. BYTE phase;
  255. int in_length;
  256. int in_num;
  257. unsigned short in_crc;
  258. unsigned short in_tcrc;
  259. int in_loc;
  260.  
  261.     BYTE queue[ALP_IN],str[2000];
  262.     int front,back;
  263.  
  264.     int p;
  265.     int background;
  266.     BYTE intrans;
  267.     BYTE no_alp;
  268.     BYTE outnum;
  269.     BYTE lastnum;
  270.  
  271.     BYTE macro_buffer[100];
  272.     BYTE *macro_ptr;
  273.  
  274.     int wait;
  275. };
  276.  
  277.  
  278.  
  279. // Declarations ued by COMPRESS.CPP
  280.  
  281.  
  282.  
  283. // Definitions used by FILEIO.CPP
  284.  
  285.  
  286. class FILEIO:public DEVICE
  287. {
  288.     int handle;
  289.     long offset,length,size;
  290.     BYTE rbuf[5000],*p_rbuf;
  291.     long l_rbuf,rbase;
  292.     
  293.     BYTE wbuf[5000],*p_wbuf;
  294.  
  295.     public:
  296.     FILEIO();
  297.     ~FILEIO();
  298.  
  299.     int gethandle(void);
  300.  
  301.     void open_file(char *path,char *name,char md,char *type,char *creator);
  302.  
  303.     void fread(void *loc,long len);
  304.     void fwrite(void *loc,long len);
  305.     char end(void);
  306.     char error(void);
  307.     void close_file(void);
  308.     void pos(long loc);
  309.     long where(void);
  310.     long file_length(void);
  311.  
  312.     virtual int put(BYTE ch);
  313.     virtual BYTE get(BYTE *ch);
  314.     char sharing;
  315.     char filename[80];
  316.  
  317. #ifdef MAC
  318.  
  319.     int    vRef;
  320. #endif
  321.     };
  322.  
  323.  
  324. // Declarations for STACK.CPP
  325. #define STACK_SIZE 100
  326.  
  327. class STACK
  328. {
  329. public:
  330.     STACK();
  331.     int pop(void);
  332.     void push(int v);
  333.     int empty(void);
  334.  
  335. private:
  336.     int location;
  337.     int stack[STACK_SIZE];
  338. };
  339.  
  340.  
  341.  
  342.  
  343.  
  344.  
  345.  
  346. #endif